<template>
	<view class="boxContent">
		<view class="title">工单数据</view>
		<view v-if="!isLoading" class="xskhtj">
			<view v-for="(item, index) in salesJbList" :key="index" class="xskhCard">
				<text>{{item.cnt}}</text>
				<text>{{item.text}}</text>
			</view>
		</view>
		<view v-else class="xskhtj flexColumn">
			<u-loading size="66" color="#ffaa00"></u-loading>
			<view style="font-size: 30rpx; font-weight: bold; margin-top: 10rpx;">加载中...</view>
		</view>
	</view>
</template>

<script>
	let that = '';
	import { apiStatistics } from '@/api/workorder.js'
	export default {
		props: {
			sys_user_id: {
				type: Number,
				default: 0
			},
			period: {
				type: String,
				default: ''
			},
			department: {
				type: String,
				default: ''
			}
		},
		data() {
			return {
				isLoading: false,
				salesJbList: []
			};
		},
		watch: {
			department: function() {
				that.getSalesJianBaoFun();
			},
			period: function() {
				that.getSalesJianBaoFun();
			}
		},
		created() {
			that = this;
			that.setJianBaoParamsFun();
			that.getSalesJianBaoFun();
		},
		methods: {
			// 设置销售简报基础数据
			setJianBaoParamsFun: function() {
				that.salesJbList = []
			},
			getSalesJianBaoFun: function() {
				that.isLoading = true;
				let reqData = {
					action: 'get_list',
					params: {
						req:{
							sys_user_id: that.sys_user_id,
							department: that.department,
							period:that.period,
							listtype:'report'
						}
						
					}
				}
				apiStatistics(reqData)
					.then(res => {
						that.isLoading = false;
						that.salesJbList = res.data;
						console.log(that.salesJbList)
					})
			}
		}
	}
</script>

<style>
	.boxContent {
		width: 100%;
		/* margin-top: 20rpx; */
/* 		margin-left: 25rpx;
		margin-top: 32rpx; */
		padding-bottom: 16rpx;
		border: 1rpx solid #dcdcdc;
		box-shadow: #adadad 0px 0px 5rpx;
		border-radius: 6rpx;
		border-radius: 16rpx;
	}

	.title {
		font-size: 24rpx;
		margin: 16rpx 0 16rpx 16rpx;
	}

	.box {
		position: relative;
		width: 100%;
		height: 160rpx;
		box-sizing: border-box;
		padding: 0 16rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding-bottom: 16rpx;
		margin-bottom: 16rpx;
	}

	.charts {
		width: 100%;
		height: 500upx;
		background-color: #FFFFFF;
	}

	.xskhtj {
		width: 100%;
		min-height: 272rpx;
		padding: 16rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		flex-wrap: wrap;
	}

	.flexColumn {
		flex-direction: column;
		justify-content: center;
	}

	.xskhCard {
		width: 33%;
		font-size: 30rpx;
		margin-bottom: 6rpx;
		padding-bottom: 12rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.xskhCard>text:first-child {
		font-weight: bold;
		color: #007AFF;
		margin-bottom: 16rpx;
	}

	.xskhCard>text:last-child {
		color: #adadad;
		font-size: 24rpx;
	}
</style>
